﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Paymentpage.aspx.cs" Inherits="WeChat.Paymentpage" %>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script type="text/javascript" src="//cdn.bootcss.com/jquery/3.1.1/jquery.js"></script>
        <script src="//cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
        <script type="text/javascript">
	    $(function () {
		$.post("AjaxSets.ashx", { functionName: "IsValue" }, function (data) {
		    window.open(data);
		var qrcode = $('#divOne').qrcode(utf16to8(data)).hide();
		console.info(qrcode);
		var canvas = qrcode.find('canvas').get(0);
		console.info(canvas);
		$('#imgOne').attr('src', canvas.toDataURL('image/jpg'));
		$.post("AjaxSets.ashx", { functionName: "Return" }, function (data) {
		    var h1 = document.getElementById('BiTi');
		    //h1.innerHTML = "保存图片，打开" + data + "进行扫一扫支付";
		    h1.innerHTML = "请长按二维码进行识别支付";
		});
		});
	    })
	    function utf16to8(str) { //转码  
		var out, i, len, c;
		out = "";
		len = str.length;
		for (i = 0; i < len; i++) {
		    c = str.charCodeAt(i);
		    if ((c >= 0x0001) && (c <= 0x007F)) {
			out += str.charAt(i);
		    } else if (c > 0x07FF) {
			out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
			out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
			out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
		    } else {
			out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
			out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
		    }
		}
		return out;
	    }
        </script>
    </head>
    <body>
    <h1 id="BiTi" style="font-size:50px;  text-align:center; margin-top:200px;"></h1>
        <div id="divOne" style="width:600px; margin:0 auto;  margin-top:300px; border:solid 0px red; height:550px;"></div> 
         <img id='imgOne' style="text-align:center; width:600px; margin:0 auto;  height:550px; margin-left:180px;" /> 
	 	<a href='index.html'  style="width:auto;  position: absolute; text-decoration:none;  font-size:45px; left:800px; line-height:80px; top:50px; width:200px; height:100px; text-align:center;  color:#fff; background-color:#04be02;border: 1px solid #04be02;" class="btn btn-default dropdown-toggle" data-toggle="dropdown">返回首页</a>
    </body>
</html>
